<?php
	//
	//This php will handle the 
	// UserFetch.java 
	// - fetchUserById function
	//
	
	//Connect to database
	include '../../dbc.php';
	
	$user = $_POST['user'];
	
	//Select non-admin and non-blocked restaurant
    $query01 = "SELECT * FROM user_follow WHERE user='$user'";
	$query01_result = mysql_query($query01);
	if(mysql_num_rows($query01_result) > 0){
		
		$i = 0;
		while($query01_result_row = mysql_fetch_array($query01_result)){
			$tmp_follow_user = $query01_result_row['user_follow'];
			
			$query02 = "SELECT * FROM user WHERE id='$tmp_follow_user' AND is_blocked='0'";
			$query02_result = mysql_query($query02);

			if(mysql_num_rows($query02_result) > 0){
				$query02_result_row = mysql_fetch_array($query02_result);
				$id[$i] = $tmp_follow_user;
				$name[$i] = $query02_result_row['name'];
				$description[$i] = $query02_result_row['description'];
				$profile_picture[$i] = $query02_result_row['profile_picture'];
				$i++;
				
			}else{
				continue;	
			}
		}
		
		
		$response["STATUS"] = "1";
		$response["NUMBER"] = $i;
		$response["ID"] = $id;
		$response["NAME"] = $name;
		$response["DESCRIPTION"] = $description;
		$response["PROFILE_PICTURE"] = $profile_picture;
		
		echo json_encode($response);
	}else{
		//Unable to get user
		$response["STATUS"] = "0";
		$response["NUMBER"] = "0";
		echo json_encode($response);
	}
	

?>